package com.demo.spring.di.java;

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * java配置依赖注入
 * @Component标记为配置类，@Bean注入返回Bean类型
 * @author Nina
 * @create 2018/8/29 下午10:42
 */
@Component
public class JavaConfig {

    @Bean
    public JavaBean2 getJavaBean2(){
        return new JavaBean2();
    }

    @Bean
    public JavaBean1 getJavaBean1(){
        JavaBean1 javaBean1 = new JavaBean1();
        javaBean1.setJavaBean2(getJavaBean2());
        return javaBean1;
    }



}
